import service from './request'

export function login(username,password){
    return service({
        url: '/api/login',
        method: 'post',
        data: {
            "username":username,
            "password":password
        }
    })
    .then(response => {
        console.log('Login successful:', response.data);
        localStorage.setItem('token',response.data.token)
        return response.data;
    })
    .catch(error => {
        console.error('Login request failed:', error);
        throw error;
    });
}